home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mgr_2 / src / atari / blit.c < prev    next >
C/C++ Source or Header  |  1990-09-23  |  5KB  |  202 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: blit.c,v 4.1 88/06/21 13:07:59 bianchi Exp $
  9.     $Source: /tmp/mgrsrc/src/oblit/RCS/blit.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/src/oblit/RCS/blit.c,v $$Revision: 4.1 $";
  12.  
  13. /*  stub bitblit code */
  14.  
  15. #include "bitmap.h"
  16. #include <linea.h>
  17.  
  18. extern char *_scrnbase;
  19. extern int _scrwidth, _scrheight, _scrplanes;
  20.  
  21. /* the atari hardware expects SRC==0x3, DST==0x05, so we have to convert
  22.    the MGR standards here
  23.  */
  24.  
  25. static char __atari[16] = {
  26.     0, 0x8, 4, 0xc,
  27.     2, 0xa, 6, 0xe,
  28.     1,   9, 5, 0xd,
  29.         3, 0xb, 7, 0xf
  30. };
  31.  
  32. static char nsrc[16] = {        /* fold no source cases */
  33.     0,0,0,0,
  34.     0xf&~DST, 0xf&~DST, 0xf&~DST, 0xf&~DST,
  35.     0xf&DST, 0xf&DST, 0xf&DST, 0xf&DST, 
  36.     0xf, 0xf, 0xf, 0xf
  37.     };
  38.  
  39. /*
  40.  *  General memory-to-memory rasterop
  41.  */
  42.  
  43. mem_rop(dest, dx, dy, width, height, func, source, sx, sy)
  44. int sx, sy, dx, dy;        /* properly clipped source and dest */
  45. int width, height;        /* rectangle to be transferred */
  46. BITMAP *source, *dest;        /* bit map pointers */
  47. int func;            /* rasterop function */
  48. {
  49.  
  50.     BBPB b;
  51.     int mindx, mindy, i;
  52.     int srcnxln, dstnxln;
  53.     int srcnxwd, dstnxwd;
  54.  
  55.     bzero(&b, sizeof(b));
  56. #ifndef NOCLIP
  57.     if (width < 0) {
  58.         dx += width;
  59.         width = -width;
  60.     }
  61.     if (height < 0) {
  62.         dy += height;
  63.         height = -height;
  64.     }
  65.     if (dx < 0) {
  66.         sx -= dx;
  67.         width += dx;
  68.         dx = 0;
  69.     }
  70.     if (dy < 0) {
  71.         sy -= dy;
  72.         height += dy;
  73.         dy = 0;
  74.     }
  75.     if (source) {
  76.         if (sx < 0) {
  77.             dx -= sx;
  78.             width += sx;
  79.             sx = 0;
  80.         }
  81.         if (sy < 0) {
  82.             dy -= sy;
  83.             height += sy;
  84.             sy = 0;
  85.         }
  86.         if ((i = sx + width - source->wide) > 0)
  87.             width -= i;
  88.         if ((i = sy + height - source->high) > 0)
  89.             height -= i;
  90.     }
  91.  
  92.     if ((i = dx + width - dest->wide) > 0)
  93.         width -= i;
  94.     if ((i = dy + height - dest->high) > 0)
  95.         height -= i;
  96.     if (width < 1 || height < 1)
  97.         return -1;
  98. #endif
  99.  
  100.     if (source) {
  101.         if (IS_SCREEN(source)) {
  102.             srcnxwd = __aline->_VPLANES + __aline->_VPLANES;
  103.             srcnxln = __aline->_VWRAP;
  104.         }
  105.         else {
  106.             srcnxwd = HI_NXWD;
  107.             srcnxln = BIT_LINE(source) << 2;
  108.         }
  109.     }
  110.  
  111.     if (IS_SCREEN(dest)) {
  112.         dstnxwd = __aline->_VPLANES + __aline->_VPLANES;
  113.         dstnxln = __aline->_VWRAP;
  114.     }
  115.     else {
  116.         dstnxwd = HI_NXWD;
  117.         dstnxln = BIT_LINE(dest) << 2;
  118.     }
  119.  
  120.     b.bb_b_wd = width;
  121.     b.bb_b_ht = height;
  122.     b.bb_plane_ct = IS_SCREEN(dest) ? _scrplanes : 1;
  123.     b.bb_fg_col = 0xf;
  124.     b.bb_bg_col = 0;
  125.     func = OPCODE(func);
  126.     if (source) {
  127.         b.bb_op_tab.fg0bg0 =
  128.         b.bb_op_tab.fg0bg1 =
  129.         b.bb_op_tab.fg1bg0 =
  130.         b.bb_op_tab.fg1bg1 = __atari[func];
  131.         b.bb_s.bl_xmin = source->x0 + sx;
  132.         b.bb_s.bl_ymin = source->y0 + sy;
  133.         b.bb_s.bl_nxwd = srcnxwd;
  134.         b.bb_s.bl_nxpl = 
  135.     (IS_SCREEN(source) && IS_SCREEN(dest)) ? 2 : 0;
  136.         b.bb_s.bl_nxln = srcnxln;
  137.         b.bb_s.bl_form = (char *)source->data;
  138.     }
  139.     else {
  140.         b.bb_op_tab.fg0bg0 =
  141.         b.bb_op_tab.fg0bg1 =
  142.         b.bb_op_tab.fg1bg0 =
  143.         b.bb_op_tab.fg1bg1 = __atari[nsrc[func]];
  144.         b.bb_s.bl_form = (char *)0xabcdef00;
  145.     }
  146.     b.bb_d.bl_xmin = mindx = dest->x0 + dx;
  147.     b.bb_d.bl_ymin = mindy = dest->y0 + dy;
  148.     b.bb_d.bl_form = (char *)dest->data;
  149.     b.bb_d.bl_nxwd = dstnxwd;
  150.     b.bb_d.bl_nxln = dstnxln;
  151.     b.bb_d.bl_nxpl = 2;
  152.     b.bb_p_addr = 0;
  153.     linea7(&b);
  154. }
  155.  
  156. #if 0
  157. /*
  158.  * function to copy the (one plane) screen image to the physical screen
  159.  */
  160.  
  161. void
  162. _update_screen(source, minx, maxx, miny, maxy)
  163.     BITMAP *source;
  164.     int minx, maxx, miny, maxy;
  165. {
  166.     BBPB b;
  167.  
  168.     if (_need_updates == 0)
  169.         return;
  170.  
  171.     if (!IS_SCREEN(source))
  172.         return;
  173.  
  174.     if (minx >= maxx || miny >= maxy)
  175.         return;
  176.     bzero(&b, sizeof(b));
  177.     b.bb_b_wd = (maxx - minx);
  178.     b.bb_b_ht = (maxy - miny);
  179.     b.bb_plane_ct = 1;
  180.     b.bb_fg_col = 3;
  181.     b.bb_bg_col = 0;
  182.     b.bb_op_tab.fg0bg0 =
  183.     b.bb_op_tab.fg0bg1 =
  184.     b.bb_op_tab.fg1bg0 =
  185.     b.bb_op_tab.fg1bg1 = S_ONLY;
  186.     b.bb_s.bl_xmin = minx;
  187.     b.bb_s.bl_ymin = miny;
  188.     b.bb_s.bl_nxwd = HI_NXWD;
  189.     b.bb_s.bl_nxpl = 2;
  190.     b.bb_s.bl_nxln = BIT_Size(source->wide, 1, 1);
  191.     b.bb_s.bl_form = (char *)source->data;
  192.     b.bb_d.bl_xmin = minx;
  193.     b.bb_d.bl_ymin = miny;
  194.     b.bb_d.bl_nxwd = __aline->_VPLANES * 2;
  195.     b.bb_d.bl_nxln = __aline->_VWRAP;
  196.     b.bb_d.bl_nxpl = 2;
  197.     b.bb_d.bl_form = _scrnbase;
  198.     b.bb_p_addr = 0;
  199.     linea7(&b);
  200. }
  201. #endif
  202.